home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Utils□□□ Divers 2 / MacCurveFit 1.2 / MacCurveFit Tuts / MacCurveFit Tuts.rsrc / TEXT_128.txt < prev    next >
Text File  |  1995-09-02  |  8KB  |  489 lines

  1. Tutorial 1.
  2.  
  3. This tutorial will illustrate how the pieces fit together and show you how to do some curve fitting.  The problem chosen here is the problem that prompted me to write MacCurveFit.  It involves a kinetic investigation of a particular free radical chemical reaction.  If you are not interested in chemistry IΓÇÖll spare you the details.
  4.  
  5. Launch MacCurveFit by double clicking its icon in the Finder.  When it has started up select OpenΓǪ from the File menu and choose ΓÇ£Product RatiosΓÇ¥ from the dialog box.  Click on the Open button and a new data window will open displaying the data from the file.
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. The first column contains the initial concentration of tri-n-butylstannane in a series of chemical reactions and the second and third columns list two ratios of reaction products.  IΓÇÖll just refer to the products as 5, 6, 7 and 8; and the ratios are ([5]+[6])/[7] and ([5]+[6])/[8].  The next step is to plot the ratios in columns B and C against the stannane concentrations in column A.  To do this choose Plot DataΓǪ from the Data menu.  A dialog box will appear and you should click on [stannane] in the left list then click the Set X Data button on the right  hand side.  Next hold down the shift key while you drag across the ([5]+[6])/[7] and ([5]+[6])/[8].  Both columns will be highlighted and you can then click the Add Y Data button.  The dialog box should be as shown below.
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. Click on the OK button and a new plot window will appear.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. The data from column B will be displayed as circles and the data from column C will be represented by squares.  LetΓÇÖs change the plot so that the ratios ([5]+[6])/[8] are represented as triangles.  Choose Data SymbolsΓǪ from the Plot menu.  Click the right arrow button to change the selected column to ΓÇ£Product Ratios:([5]+[6])/[8]ΓÇ¥.  Then click the triangle symbol followed by the OK button.
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. The plot will be redrawn with triangles marking the data from column C.  Next change the title of the plot by choosing TitleΓǪ from the Plot menu.  Type ΓÇ£Dependence of Product Ratios on Stannane ConcentrationΓÇ¥ into the dialog box and click OK.
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126. Most changes are easy to undo in MacCurveFit.  To see this choose Undo Plot Title from the Edit menu and then Redo Plot Title from the same menu.
  127.  
  128. Finally letΓÇÖs get the axes looking the way we want (IΓÇÖll assume for the moment that we agree on style).  Bring up the axes dialog box by choosing AxesΓǪ from the Plot menu.  Make the necessary changes so the dialog box matches the figure below.  Then click the Y Axis radio button and set things to match the figure at the top of the next page.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. The plot will now look like the one shown below.
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. At last itΓÇÖs time to do some curve fitting.  WeΓÇÖll fit the function  y = ax + b + c/x to each data column.  Summon the curve fit window by selecting Curve FitΓǪ from the Fit menu.  Choose the function ΓÇ£rational funcΓÇ¥ from the function popup menu.  If it is not in the menu quit the program and check that the supplied ΓÇ£FunctionsΓÇ¥ folder is in the same folder as the MacCurveFit application.  
  196.  
  197. Next give the fitting algorithm a starting point to work from, type 1 into the cells for a, b and c.  Then click on the Fit button.  You will see the SSE, the R2 and the coefficients updated every iteration.  The algorithm quickly arrives at a best fit as shown below.
  198.  
  199. Earlier I mentioned that MacCurveFitΓÇÖs printing code always strives to give the best results possible.  If you print this document you may be puzzled by the poor quality.  To show you how the whole window looks as opposed to how the plot itself looks, I have simply presented a screen dump (command-shift-3) in this manual.  If you print the plot directly from the application at this point youΓÇÖll be more satisfied by the printing quality.
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250. To fit the function through the second set of data click the right arrow button in the curve fit window to select the data in column C.  Repeat the earlier proceedings, namely choose the rational function and enter 1 into the cells for a, b and c.  Click the Fit button.  You should now have a plot that looks like the one on the next page.
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302. To illustrate how to apply error bars letΓÇÖs display them on the data in column B at 10% of size of the data point.  Select Error BarsΓǪ from the Plot menu and select Fixed Percent.  Enter ΓÇÿ10ΓÇÖ into the edit field as shown in the dialog box and then click OK.
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327. The plot will now have error bars as shown below.  Note that the point at [stannane] = 0.25 M has a smaller error bar than the point at [stannane] = 1.50 M, this shows that the error bar size is proportional to the y value of the data point, ([5]+[6])/[7].
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355. Now letΓÇÖs remove these error bars and use the values in the error_1 data column as error bars.  Open the error bar dialog box again and select none for the ratio ([5]+[6])/[7].  Next click the right arrow button to select the next data set.  Click the Data Column button and a popup menu and list will appear.  In the popup menu select the data window Product Ratios.  Then click on the error_1 data column in the list.  Click OK and the new error bars will be displayed in the plot.
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404. Whenever the data values in the error_1 column are altered, the plot will be automatically redrawn.  Finally save the plot by selecting Save from the File menu while either the plot or curve fit window is the front window.  
  405.  
  406. The error bars can be used to weight the data points during curve fitting.  In this example the errors corresponding to stannane concentrations below 0.1 M are much higher than those for stannane concentrations above 0.1 M.  Hence weighted curve fitting will give more emphasis to the data points at higher concentrations.
  407.  
  408. To perform the weighted curve fit, bring the fit window to the front and then select Weight Data... from the Fit menu.  Select the 'Product Ratios:([5]+[6])/[8]' data set using the arrowed buttons and then select Use errors.  The popup menu and list will default to the column containing the error bars however any data column can be chosen.  Finally click OK.
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429. On clicking the Fit button in the fit window, the weighted curve fit will be performed.  The fit obtained differs from the previous unweighted fit in that the region of the curve above 0.1 M stannane lies much closer to the data points.  This is most obvious when looking at the point corresponding to a stannane concentration of 0.25 M.
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455. Now lets calculate some x and y values from the fitted curve.  Click the arrowed buttons in the Fit window to select the ([5] + [6])/7) data set.  Then select Predict Single YΓǪ from the Fit menu.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470. Enter 0.9 into the x field and then click the Calculate button.  This shows that at a stannane concentration of 0.9 M the product ratio is 0.97567.  An inspection of the plot reveals that this ratio can be obtained at two stannane concentrations, 0.9 M and at another very low concentration.  To find out what this other concentration is we can select Predict Single X from the Fit menu.
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485. Type 0.97567 into the y field and click Calculate.  The value 8.99997E-1 will appear in the right field as the corresponding x value.  The calculation requires a starting value, since we didn't supply one the program took the midpoint of the x range of the plot, namely 0.8.  This caused the value 0.899997 to be found since it was the closest x value that gave the desired y value.  To direct the calculation to give us the other stannane concentration we can enter 0.001 into the x value field and then click the Calculate button.  This time the result 4.62496E-03 appears in the x field.
  486.  
  487. Now back to the chemistry, from the values of a, b and c, it was possible to calculate the kinetic rate constants of certain steps in the free radical reaction I was investigating.  Those seeking a dose of free radical kinetics are referred to Journal of Organic Chemistry  1992, 57, 4954.
  488.  
  489.